var ctx = "/" + location.pathname.split("/")[1];
var param = function() {
	var param = {};
	var search = window.location.search;

	if (!search || search.length < 2)
		return param;

	var keyValues = search.substring(1).split("&");

	for (var i = 0; i < keyValues.length; i++) {
		var kv = keyValues[i].split("=");
		param[kv[0]] = kv.length > 1 ? kv[1] : "";
	}
	return param;
};
//日期格式化扩展
Date.prototype.format = function(format){
	var o = {
		"M+" : this.getMonth()+1, //month
		"d+" : this.getDate(), //day
		"h+" : this.getHours(), //hour
		"m+" : this.getMinutes(), //minute
		"s+" : this.getSeconds(), //second
		"q+" : Math.floor((this.getMonth()+3)/3), //quarter
		"S" : this.getMilliseconds() //millisecond
	}

	if(/(y+)/.test(format)) {
		format = format.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));
	}

	for(var k in o) {
		if(new RegExp("("+ k +")").test(format)) {
			format = format.replace(RegExp.$1, RegExp.$1.length==1 ? o[k] : ("00"+ o[k]).substr((""+ o[k]).length));
		}
	}
	return format;
} ;
var transfer = function(data){
	return data.replace(/\(/g, "[").replace(/\)/g, "]");
}
//日期处理
var dealDate = function(data){
	if(data == null){
		return "";
	}
	return new Date(data).format("yyyy-MM-dd"); ;
}
//获取图片的实际高度
function getImage(url){
	var img = new Image();
	img.src = url;
	// 如果图片被缓存，则直接返回缓存数据
	if(img.complete){
	    return {width:img.width,height:img.height};
	}else{
        // 完全加载完毕的事件
	    img.onload = function(){
			return {width:img.width,height:img.height};
		}
    }
}
if(typeof juicer != "undefined"){
	juicer.register('transfer', transfer);
	juicer.register('dealDate', dealDate);
}